home *** CD-ROM | disk | FTP | other *** search
- /***
- * URLHelperComponent.c
- *
- * This is the URLHelper dispatch routine...
- *
- ***/
-
- #include "debug_me.h"
-
- #include "URLHelperComponent.h"
- #include "URLHelperComponentPrivate.h"
-
- /**
- * URLHelperDispatcher
- *
- * This routine is called as the entrace to the component. We dispatch to the other fellows
- *
- **/
-
- #ifdef DEBUG_IT
- pascal ComponentResult URLHelperDispatcher (ComponentParameters *params, Handle storage)
- #else
- pascal ComponentResult main (ComponentParameters *params, Handle storage)
- #endif
-
- {
- ComponentFunctionUPP theJob = 0;
- ComponentResult theCErr;
-
- /**
- ** If the what code is less than zero, then we have a component manager
- ** request. We have to create the UPP for each routine. Deallocate it at the end
- ** when we are done with it.
- **/
-
- if (params -> what < 0) {
- switch (params -> what) {
- case kComponentOpenSelect: // Open this component
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperOpen,
- uupURLHelperOpen, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kComponentCloseSelect: // Close this component
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperClose,
- uupURLHelperClose, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kComponentCanDoSelect: // Can we do this function?
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperCanDo,
- uupCanDo, GetCurrentISA());
- theCErr = CallComponentFunction (params, theJob);
- break;
-
- case kComponentVersionSelect: // What version is this component ?
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperVersion,
- uupVersion, GetCurrentISA());
- theCErr = CallComponentFunction (params, theJob);
- break;
-
- case kComponentTargetSelect: // We are being captured by another component
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperTarget,
- uupURLHelperTarget, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- default: // A request code we don't deal with
- theCErr = paramErr;
- break;
-
- }
-
- } else {
-
- /**
- ** One of our request codes needs to be processed!!! Yeah!
- **/
-
- switch (params -> what) {
-
- case kDoGetMirrorList: // Return ref to a installed mirror list
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperGetMirrorList,
- uupURLHelperGetMirrorList, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoNewMirrorList: // Return ref to new installed mirror list
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperNewMirrorList,
- uupURLHelperNewMirrorList, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoAddMirror: // Add a new mirror to the list
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperAddMirror,
- uupURLHelperAddMirror, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoNumberOfMirrors: // How many useful mirrors
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperNumberOfMirrors,
- uupURLHelperNumberOfMirrors, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoGetUsableMirror: // Return a mirror we can use for subst.
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperGetUsableMirror,
- uupURLHelperGetUsableMirror, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoNewParseState: // Make up a new parse state here!
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperNewParseState,
- uupURLHelperNewParseState, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoDisposeParseState: // Dispose of a parse state here!
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperDisposeParseState,
- uupURLHelperDisposeParseState, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- case kDoGetMirrorRep: // Replace one mirror with another!
- theJob = (ComponentFunctionUPP) NewRoutineDescriptor (_URLHelperGetMirrorRep,
- uupURLHelperGetMirrorRep, GetCurrentISA());
- theCErr = CallComponentFunctionWithStorage (storage, params, theJob);
- break;
-
- default:
- theCErr = paramErr;
- break;
- }
- }
-
- /**
- ** Done. Return the result and dispose of the UPP if we used it
- **/
-
- if (theJob){
- DisposeRoutineDescriptor (theJob);
- }
-
- return theCErr;
- }
-